package cn.lixin.fallback;

import cn.lixin.feignclient.UserFeignClient;
import cn.lixin.to.UserTo;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * UFCFallbackFactory = UserFeignClientFallbackFactory
 * */
@Component
public class UFCFallbackFactory implements FallbackFactory<UserFeignClient> {
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public UserTo getById(Long id) {
                throwable.printStackTrace();
                return new UserTo(-1L,"服务器错误");
            }
        };
    }
}
